package com.evil.enterprise.controller;

import com.evil.application.api.RemoteApplicationViewService;
import com.evil.application.pojo.dto.view.ApplicationViewReqDTO;
import com.evil.application.pojo.dto.view.ApplicationViewRespDTO;
import com.evil.application.pojo.dto.view.ModifyApplicationViewReqDTO;
import com.evil.common.core.entity.R;
import com.evil.common.log.annotation.RequestLogAnnotation;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 应用视图
 *
 * @author liyang
 * @date 2022-08-08 00:00
 */
@Slf4j
@RestController
@AllArgsConstructor
@RequestMapping("/application/view")
public class ApplicationViewController {

    private final RemoteApplicationViewService remoteApplicationViewService;

    /**
     * 应用视图详情
     *
     * @param applicationViewReqDTO applicationViewReqDTO
     * @return R
     */
    @PostMapping("/info")
    public R<ApplicationViewRespDTO> viewInfo(@Validated @RequestBody ApplicationViewReqDTO applicationViewReqDTO) {
        return R.success(remoteApplicationViewService.viewInfo(applicationViewReqDTO));
    }

    /**
     * 编辑应用视图
     *
     * @param modifyApplicationViewReqDTO modifyApplicationViewReqDTO
     * @return R
     */
    @RequestLogAnnotation(isSaveRequestData = false)
    @PostMapping("/modify")
    public R<?> modify(@Validated @RequestBody ModifyApplicationViewReqDTO modifyApplicationViewReqDTO) {
        remoteApplicationViewService.modify(modifyApplicationViewReqDTO);
        return R.success();
    }
}
